//
//  ConsumptionFlowViewController.m
//  跨界收
//
//  Created by Allen on 2018/10/27.
//  Copyright © 2018年 gztx. All rights reserved.
//

#import "ConsumptionFlowViewController.h"
#import "CheckViewController.h"
#import "FlowTableViewCell.h"

@interface ConsumptionFlowViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UISegmentedControl *monthdaySegmentedControl;
@property (weak, nonatomic) IBOutlet UIButton *agoBtn;
@property (weak, nonatomic) IBOutlet UIButton *houBtn;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UITableView *tableview;

@end

@implementation ConsumptionFlowViewController
- (void)createRightItem
{
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    rightBtn.frame = CGRectMake(0, 0, 60, 30);
    [rightBtn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [rightBtn setImage:[UIImage imageNamed:@"check"] forState:UIControlStateNormal];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
    self.navigationItem.rightBarButtonItem = rightItem;
}
- (void)click
{
    CheckViewController *checkVC = [[CheckViewController alloc]initWithNibName:@"CheckViewController" bundle:nil];
    checkVC.controlIndex = self.monthdaySegmentedControl.selectedSegmentIndex;
    [self.navigationController pushViewController:checkVC animated:YES];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}
- (IBAction)clickControl:(UISegmentedControl *)sender {
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"消费流水";
    [self createRightItem];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    [self.tableview registerNib:[UINib nibWithNibName:@"FlowTableViewCell" bundle:nil] forCellReuseIdentifier:@"Cell"];
    // Do any additional setup after loading the view from its nib.
}
#pragma mark -- UITableViewDelegate/DataSource --
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UILabel *dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(15.0, 0, 80, 20)];
    dateLabel.font = [UIFont systemFontOfSize:14.0];
    dateLabel.textAlignment = NSTextAlignmentLeft;
    dateLabel.textColor = [UIColor cz_colorWithHex:0xC6C6C6];
    dateLabel.text = @"2018-09-30";
    
    UILabel *moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(95, 0,SCREEN_WIDTH-30.0-60.0, 20)];
    moneyLabel.font = [UIFont systemFontOfSize:14.0];
    moneyLabel.textAlignment = NSTextAlignmentRight;
    moneyLabel.textColor = [UIColor cz_colorWithHex:0xC6C6C6];
    moneyLabel.text = @"共7笔 V678。00";
    
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-30.0, 20)];
    headerView.backgroundColor = [UIColor cz_colorWithHex:0xF1F1F1];
    [headerView addSubview:moneyLabel];
    [headerView addSubview:dateLabel];
    return headerView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20.0;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 10;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 70;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"Cell";
    FlowTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[FlowTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
    }
//    [cell setFlowData];
    return cell;
}
@end
